package com.gm.commonlib.network.basenetwork.ssl;


import com.youth.banner.util.LogUtils;

import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;

import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSocketFactory;
import javax.net.ssl.TrustManager;

public class SslSocketFactoryImpl {

    public static SSLSocketFactory getSslSocketFactory() {
        try {
            SSLContext sslContext = SSLContext.getInstance("TLSv1.2");
            sslContext.init(null, new TrustManager[]{new UnSafeTrustManager()}, new SecureRandom());
            return new NoSSLv3SocketFactory(sslContext.getSocketFactory());
        } catch (NoSuchAlgorithmException | KeyManagementException e) {
            LogUtils.d(e.toString());
        } catch (Exception e) {
            LogUtils.d(e.toString());
        }
        return null;
    }
}
